package com.cheng.fmmall.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * Swagger会帮助我们生成接口文档
     * 1。配置生成的文档的基本信息
     * 2。配置接口生成规则
     */

    /**
     * Docket：封装了接口文档信息
     */
    @Bean
    public Docket getDocket() {

        // ApiInfo：指定生成的文档中的封面信息，文档标题、版本、作者
        ApiInfo build = new ApiInfoBuilder().title("《锋迷商城》后端接口说明")
                .description("此文档详细说明了锋迷商城后端接口规范")
                .version("v 2.0.1")
                .contact(new Contact("程明杨", "www.chengmingyang.com", "chengmingyang1996@163.com"))
                .build();

        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(build)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.cheng.fmmall.controller"))
                .paths(PathSelectors.any())
                .build();

        return docket;
    }
}





